import { TableProps, Input } from "tdesign-vue-next";
import { computed } from "vue";

export default computed<TableProps["columns"]>(() => [
  {
    colKey: "name",
    title: "名字",
    width: 300,
    edit: {
      component: Input,
      props: {
        clearable: true,
        placeholder: "请输入姓名",
      },
      validateTrigger: "change",
      abortEditOnEvent: ["onEnter"],
      onEdited: (context) => {
        Object.assign(context.row, context.newRowData);
      },
      rules: [
        { required: true, message: "不能为空" },
        { max: 10, message: "字符数量不能超过 10", type: "warning" },
      ],
    },
  },
  { colKey: "age", title: "年龄", width: 100, sorter: true },
  { colKey: "sex", title: "性别", width: 120, cell: "sex", sorter: true },
  { colKey: "address", title: "地址", ellipsis: true },
]);
